﻿using Lcygcc.Domain.Repository.Entity;
using Lcygcc.Infrastructure.Logs;
using Lcygcc.Infrastructure.Repository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lcygcc.Domain.Repository.DB
{
    /// <summary>
    /// 人事资料仓储类
    /// </summary>
    public class PersonRepository
    {
        /// <summary>
        /// 获取Oracle人事资料
        /// </summary>
        /// <returns></returns>
        public List<OraclePerson> GetPersonsByOracle()
        {
            List<OraclePerson> personList = new List<OraclePerson>();
            OraclePerson person = new OraclePerson();
            string sql = "";
            try
            {
                sql = "select * from T_PERSON";
                DataTable dt = OracleHelper.ExecuteDataTable(sql, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        person.Name = dr["Name"].ToString();
                        person.PersonNo = dr["PersonNo"].ToString();
                        person.Gender = int.Parse(dr["Gender"].ToString());
                        person.Phone = dr["Phone"].ToString();
                        personList.Add(person);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("----获取Oracle人事异常---", ex);
            }
            
            return personList;
        }
    }
}
